package org.xilin

class Book {
    String      name
    String      description
    Float       price
    Float       extraFee
    Integer     stock
    Integer     reserve
    Semester    semester
    String      category
  
    static String[] categories = ['CHINESE', 'MATH', 'OTHER']

    static transients = ['categories']

    static constraints = {
        name        (size:2..60, unique:true, blank:false)
        price       scale:2
        extraFee    (scale:2, nullable:true)
        stock       min:0
        reserve     min:0
        semester    (nullable:true)
        category    (nullable:true)
    }

    static mapping = {
        version false
        cache true
    }

    String toString() {
        name
    }
}
